name: daily

on:
  schedule:
    # Run every day at noon UTC
    - cron: '0 12 * * *'

jobs:
  jruby_tests:
    if: false
    # if: ${{ github.repository_owner == 'activeadmin' }} # don't run scheduled workflow on forks
    name: test (${{ matrix.ruby }}
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
        ruby:
          - jruby-9.4
    env:
      JRUBY_OPTS: -J-Xmx1024m --dev
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - name: Setup git for test app setup
        run: |
          git config --global user.email activeadmin@ci.dummy
          git config --global user.name ActiveAdmin
      - name: Create test app
        run: bin/rake setup
      - name: Restore cached RSpec runtimes
        uses: actions/cache@v3
        with:
          path: tmp/parallel_runtime_rspec.log
          key: runtimes-rspec-${{ matrix.ruby }}-${{ hashFiles('tmp/parallel_runtime_rspec.log') }}
      - name: Run RSpec tests
        run: |
          bin/parallel_rspec spec/
          RSPEC_FILESYSTEM_CHANGES=true bin/rspec
      - name: Restore cached cucumber runtimes
        uses: actions/cache@v3
        with:
          path: tmp/parallel_runtime_cucumber.log
          key: runtimes-cucumber-${{ matrix.ruby }}-${{ hashFiles('tmp/parallel_runtime_cucumber.log') }}
      - name: Run Cucumber features
        run: |
          bin/parallel_cucumber --fail-fast
          bin/cucumber --profile filesystem-changes
          bin/cucumber --profile class-reloading
      - name: Run bug report template
        run: ACTIVE_ADMIN_PATH=. ruby tasks/bug_report_template.rb
